program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  x0, y0, x1, y1, x2, y2, a, b, c: integer;
  d, dp, xp, yp:real;
begin
  writeln ('Enter the segment and point');
  Readln (x1, y1, x2, y2, x0, y0);
  a:=y1-y2;
  b:=x2-x1;
  c:=y2*x1-x2*y1;
  d:=(a*x0+b*y0+c)/(sqrt(a*a+b*b));
  xp:=x0-a*d/sqrt(a*a+b*b);
  yp:=y0-b*d/sqrt(a*a+b*b);
  if ((x2-xp)*(x1-xp)<=0) and ((y2-yp)*(y1-yp)<=0) then
    dp:=d
  else
    if (sqrt((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1)) > sqrt((x0-x2)*(x0-x2)+(y0-y2)*(y0-y2))) then
      dp:= sqrt((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1))
    else
      dp:= sqrt((x0-x2)*(x0-x2)+(y0-y2)*(y0-y2));
  dp:=abs(dp);
  Writeln (dp:0:4);
  readln;
end.
